﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{

    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            double sum = 0;
            double avg = 0;

            try
            {
                while (true)
                {
                    Console.WriteLine("1、输入成绩2、计算结果");
                    int key = int.Parse(Console.ReadLine());
                    switch (key)
                    {
                        case 1:
                            Console.WriteLine("请输入成绩");
                            double score = double.Parse(Console.ReadLine());
                            Students s1 = new Students(score);

                            ht.Add(s1,score);
                            sum += score;
                            break;
                        case 2:
                            avg = sum / ht.Count;

                            Console.WriteLine("平均分："+avg);
                            Console.WriteLine("总分"+sum);
                            Console.WriteLine("总人数"+ht.Count);
                            break;
                        default:
                            break;
                    }


                }


            }
            catch (FormatException)
            {
                Console.WriteLine("异常已处理");

            }
            catch (OverflowException)
            {
                Console.WriteLine("异常已处理");
            }

            catch (Exception)
            {
                Console.WriteLine("异常已处理");
            }
            finally
            {
                Console.WriteLine("最终处理完释放资源");
            }

        }

    }
}
